Skip to content

Conversation

roussosalex
Copy link

A simple alternative to the std::vector approach. Makes it easier to supply a pointer and size for arbitrary binary blobs.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@aminroosta
Copy link
Collaborator

@roussosalex Thank you for the PR, lack of operator >> for raw pointers is a valid point.
In fact we had a discussion in #122 on the interface of next version (v4).

My proposal is to change the meaning of operator >> for vector<T>.

// single row blob
vector<int> vblob;
db << "select numbers from tbl where id = 1" >> blob_t(vblob);
// multiple row int
vector<int> vrows;
db << "select age from tbl;" >> vrows;

The std::vector is an example here, this could/should work for all standard containers.
blob_t can be partially specialized for different types (blob_t<vector<T>>, blob_t<T*,size_t> or blob_t<span<T>>).
Heres is POC for blob_t #125

@roussosalex
Copy link
Author

@aminroosta Thanks for the quick response.
Your proposal seems reasonable, especially because specializing blob_t is a much cleaner solution than overloading the operator>> for custom types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants